package edu.zut.hb.ambition.base.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Optional;


import org.springframework.data.domain.Example;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.PagingAndSortingRepository;

import edu.zut.hb.ambition.base.domain.BaseEntity;


/**
 * Generic DAO (Data Access Object) with common methods to CRUD POJOs.
 * Implemented with Spring-Data Repository
 * <p>
 * Extend this interface if you want type safe (no casting necessary) DAO's for
 * your domain objects.
 *
 * @param <T>  a type variable, Entity
 * @param <PK> the primary key for that type，Entity Id
 * @author <a href="mailto:ming616@gmail.com">Liu Xiaoming</a>
 */
@NoRepositoryBean
public interface GenericDao<T extends BaseEntity<PK>, PK extends Serializable> extends PagingAndSortingRepository<T, PK> {

	List<T> findAll(Example<T> ex);

	<S extends T> S save(S var1);

	<S extends T> Iterable<S> saveAll(Iterable<S> var1);

	Optional<T> findById(PK var1);

	boolean existsById(PK var1);

	Iterable<T> findAll();

	Iterable<T> findAllById(Iterable<PK> var1);

	long count();

	void deleteById(PK var1);

	void delete(T var1);

	void deleteAll(Iterable<? extends T> var1);

	void deleteAll();

}